<?php 
	$data['menu'] = 'module';
	$data['title'] = '产品分类';
	$data['site_url'] = site_url('manager/goods/classes/');
	$data['csses'] = array('js/plug/treeTable/css/jquery.treeTable.css');
	$data['jses'] = array('js/plug/treeTable/js/jquery.treeTable.js');
	$this->load->view('manager/header',$data);
?>
<div class="crumbs">当前位置：<a href="#">模块管理</a> &gt; <a href="#">产品设置管理</a> &gt; <span class="silver">产品分类</span></div>
<div class="tip tip-b">
    <p class="alert noclose"><i class="icon"></i>产品分类：<a class="steelBlue" href="#"></a></p>				
</div>
<div class="list-tab">
	<ul>
		<li <?php if($action == 'list') echo 'class="cur"'?>><a href="<?php echo site_url('manager/goods/classes/index/');?>">产品分类列表</a></li>
		<li <?php if($action == 'add') echo 'class="cur"'?> title="新增产品分类"><a href="<?php echo site_url('manager/goods/classes/add/');?>" title="新增产品分类">新增产品分类</a></li>
		<?php if($action == 'edit')
			echo '<li class="cur" title="编辑产品分类">编辑产品分类</li>';
		?>
	</ul>
</div>
<?php if($action == 'list'){?>
<script type="text/javascript">
	$(document).ready(function($) {
	    $("#tableTree").treeTable();
	    // Make visible that a row is clicked
	    $("table#tableTree tbody tr").live('mousedown',function() {
	      $("tr.selected").removeClass("selected"); // Deselect currently selected rows
	      $(this).addClass("selected");
	    });
	});
</script>
<table id="tableTree" border="0" cellpadding="0" cellspacing="0">
	<thead>
		<tr>
			<th style="width:auto;">名称</th>
			<th width="100px">产品类型</th>
			<th width="100px">商家返点(%)</th>
			<th width="100px">分类导航</th>
			<th width="100px">排序</th>
			<th width="200px">操作</th>
		</tr>
	</thead>
	<tbody>
		<?php 
		function tableTree($list) {
			if(isset($list))
				foreach ($list as $item) {
					$isChildren = isset($item['childs']);
					echo '<tr id=node_',$item['id'],' class="',($isChildren?'parent ':''),($item['parentid']!=0?'child-of-node_'.$item['parentid']:''),'">
							<td><input type=checkbox value=',$item['id'],'/><span class=',($isChildren?'folder':'file'),'>',$item['name'],'</span></td>
							<td><a href=',site_url('manager/goods/type/edit/'.$item['typeid']),'>',$item['typename'],'</a></td>
							<td>',$item['rebate'],'</td>
							<td>',$item['isshow']?'显示':'不显示','</td>
							<td>',$item['sort'],'</td>
							<td>
								<a class=iconAdd href=',site_url('manager/goods/classes/add/'.$item['id']),' title=添加子类> + </a>
								<a class=iconEdit href=',site_url('manager/goods/classes/edit/'.$item['id']),' title=编辑> # </a>',
								(!$isChildren?
								'<a class="op_ajax iconDel" href='.site_url('manager/goods/classes/dodelete/'.$item['id']).' title=删除> x </a>':
								'<a class=iconNull></a>'),
							'</td>
						</tr>';
					if($isChildren){
						tableTree($item['childs']);
					}
				}
		}
		tableTree($list);
		?>
	</tbody>
</table>
<?php }else if($action == 'add' || $action == 'edit'){
	echo $form;
}?>
<?php $this->load->view('manager/footer');?>